using System;

namespace L2NH.Core.Domain
{
   public abstract class Entity : IEquatable<Entity>
   {
      public virtual int Id { get; protected set; }

      public virtual bool Equals(Entity other)
      {
         if (ReferenceEquals(null, other)) return false;
         if (ReferenceEquals(this, other)) return true;
         if (GetType() != other.GetType()) return false;
         return other.Id == Id;
      }
      public override bool Equals(object obj)
      {
         return Equals(obj as Entity);
      }
      public override int GetHashCode()
      {
         return (GetType().FullName + Id).GetHashCode();
      }
      public static bool operator ==(Entity left, Entity right)
      {
         return Equals(left, right);
      }
      public static bool operator !=(Entity left, Entity right)
      {
         return !Equals(left, right);
      }
   }
}